package com.wang.exam.controller;

import com.wang.exam.pojo.ExaminationSubjects;
import com.wang.exam.pojo.JavaWebExam;
import com.wang.exam.service.TestQuestionsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class TestQuestionController {
    private String test_name;
    @Autowired
    TestQuestionsService testQuestionsService;
    @RequestMapping("/exam/examTests")
    public String getQuestion(@Param("course_id") Integer course_id){
        List<ExaminationSubjects> examinationSubjects = testQuestionsService.getTestName(course_id);
        this.test_name = examinationSubjects.get(0).getTest_name();
        if(examinationSubjects.size()==1){
            return "testPaper";
        }
        return "Error2";
    }
    @RequestMapping("/testContent")
    @ResponseBody
    public Object getTestContent(){
        List<JavaWebExam> list = testQuestionsService.getAllQuestion(test_name);
        return list;
    }

}
